<!DOCTYPE html>
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>个人中心-admin账期-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>
    <link href="public/css/yuan.css" rel="stylesheet" type="text/css"/>
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
</head>
<body>
<div class="bg">
    <!--common - head -->
    <?php $this->load->view('common/header.php'); ?>
    <!--common - head end-->
    <div class="container mt30">
        <div class="my-center-container">
            <?php $this->load->view('member/personal_left.php'); ?>
            <div class="my-center-right" style="overflow:visible; border: none;background-color: #f9f9f9">
                <div class="my-center-chat-box-wrapper">
                    <div class="chat-box">
                        <div class="chat-box-top">
                            <div class="yuan">
                                <div class="yuan_bl1"></div>
                                <div class="yuan_text">总额度 <br>¥ <em
                                            class="num-all"><?= $admin['account_period_quota'] ?></em></div>
                                <p class="yuan_ky">
                                    可用额度<br>
                                    <span class="num-box color-red">￥<em
                                                class="num-ky"><?= $admin['account_period_quota'] - $admin['account_period_quota_used'] ?></em></span>
                                    <span class="num-box-small"> 最近需还款 <em
                                                class="color-red">￥<?= $unpayorder['moneyTotal']?$unpayorder['moneyTotal']:0 ?></em></span>
                                </p>
                                <p class="yuan_dhk">
                                    待还款金额<br>
                                    <span class="num-box">￥<em
                                                class="num-dhk"><?= $unpayorder['moneyTotal']?$unpayorder['moneyTotal']:0 ?></em></span>
                                </p>
                            </div>

                        </div>
                       <!--  <p class="chat-box-btm">
                            <span class="tit">最近需还款日期 : 400</span>
                            <span class="span02">剩余4天</span>
                            <a href="javascript:;">立即还款</a>
                        </p> -->
                    </div>
                    <div class="chat-cont">
                        <p class="p-tit p-tit-dot">
                            账期：<em><?= $admin['account_period_settlement_time'] ?>天（逐次开票）</em>
                        </p>
                        <p class="p-tit">
                            额度：<em><?= $admin['account_period_quota'] ?></em>
                        </p>
                        <p class="p-tit p-tit-dot">
                            账期还款
                        </p>
                        <p class="p-intro ">
                            未还订单金额：￥<?= $unpayorder['moneyTotal']?$unpayorder['moneyTotal']:0 ?>
                        </p>
                        <p class="p-intro ">
                            未还订单笔数：<?= $unpayorder['count'] ?>
                        </p>
                        <p class="p-tit p-tit-dot">
                            账期采购：（截至当前使用账期支付）：
                        </p>
                        <p class="p-intro ">
                            累计采购金额：￥<?= $order['moneyTotal']?$order['moneyTotal']:0 ?>
                        </p>
                        <p class="p-intro ">
                            累计采购次数：<?= $order['count'] ?>
                        </p>
                    </div>
                </div>

                <div class="my-center-right-cont" style="padding: 0;">
                    <div class="corporate-invoice-table-box mt15 w100 bg-fff border-box">
                        <table border="1" class="corporate-invoice-tab">
                            <thead>
                            <tr>
                                <th width="60">序号</th>
                                <th width="100">下单账号</th>
                                <th width="70">订单状态</th>
                                <th width="130">支付时间</th>
                                <th width="80">还款金额</th>
                                <th width="90">最后还款日期</th>
                                <th width="65">

                                    <select class="reimbursement-classification-select" name="quiz3"
                                            onchange="s_click(this)">
                                        <option value="" <?php if ($status_id == ''): ?>selected<?php endif; ?>>全部
                                        </option>
                                        <option value="0" <?php if ($status_id == "0"): ?>selected<?php endif; ?>>待还款
                                        </option>
                                        <option value="1" <?php if ($status_id == '1'): ?>selected<?php endif; ?>>已还款
                                        </option>
                                    </select>
                                </th>
                                <th>
                                    <form method="get" action="">
                                        <input type="text" placeholder="搜索订单号" name="ordersn" value="<?= $ordersn ?>"
                                               class="reimbursement-classification-input">
                                    </form>
                                </th>
                        
                                <th width="180">
                                    <span class="month-prev pre">上月</span>
                                    <div class="month-now">
                                        <input type="text" name="date" id="date" lay-verify="date"
                                               value="<?= isset($_GET['date']) ? $_GET['date'] : date('Y-m-d', time()) ?>"
                                               placeholder="选择日期"
                                               autocomplete="off" class="layui-input">
                                    </div>
                                    <span class="month-next next">下月</span>
                                </th>
                            </tr>
                            </thead>
                            <tbody>

                            <?php foreach ($result as $k=>$itrm): ?>
                                <tr>
                                    <td><?= $k+1 ?></td>
                                    <td><a href="javascript:;" title="<?= $itrm['username'] ?>"><?= $itrm['username'] ?></a></td>
                                    <td>交易成功</td>
                                    <td><?= str_replace('-','/',date("Y-m-d",strtotime($itrm['order_payment_at']))) ?></td>
                                    <td><?= $itrm['zq_money'] ?></td>

                                    <td><?php if($itrm['actual_repayment_date'] !=""):?><?= str_replace('-','/',date("Y-m-d",strtotime($itrm['actual_repayment_date']))) ?><?php endif;?></td>

                                    <?php if ($itrm['st'] === "0"): ?>
                                        <td>待还款</td>
                                    <?php else: ?>
                                        <td>已还款</td>
                                    <?php endif; ?>
                                    <td><?= $itrm['order_bn'] ?></td>
                                 
                                    <td>
                                        <?php if ($itrm['st'] === "0"): ?>
                                            <a href="<?php echo base_url()?>pay/index?bn=<?=$itrm['bill_bn']?>" class="btn-chat-box-btm">立即还款</a>
                                        <?php else: ?>
                                            实际还款日：<?= str_replace('-','/',date("Y-m-d",strtotime($itrm['actual_repayment_date']))) ?><br>

<!--                                            <p class="payment_end">-->
<!---->
<!--                                                实际还款日：--><?//= str_replace('-','/',date("Y-m-d",strtotime($itrm['actual_repayment_date']))) ?><!--<br>-->
<!--                                                恢 复 额-->
<!--                                                度：￥--><?//= $admin['account_period_quota'] - $admin['account_period_quota_used'] ?>
<!--                                            </p>-->
                                        <?php endif; ?>
                                    </td>
                                </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                        <!--<table class="layui-hide" id="test"></table>-->
                        <div class="corporate-invoice-page-box">
                            <a href="<?= $preurl ?>" class="page-prev">上一页</a>
                            <a href="<?= $nexturl ?>" class="page-next">下一页</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('common/bottom.php'); ?>
<div class="mask none"></div>
<div class="pop corporate-invoice-img-pop none">
    <a href="javascript:;" class="close"></a>
    <img class="corporate-invoice-img" src="" alt="">
</div>
<script type="text/javascript" src="public/js/jquery.min.js"></script>
<script src="public/js/layui/layui.js"></script>
<script type="text/javascript" src="public/js/index.js"></script>
<script type="text/javascript" src="public/js/owl.carousel.min.js"></script>
<script>
    $(function () {
        //初始化
        var bl = parseInt($('.num-ky').html());
        var num_all = $('.num-all').html();

        function delcommafy(num) {//去除千分位中的‘，’
            num = num.replace(/,/gi, '');
            return num;
        }

        var all = delcommafy(num_all);
        var bl_all = parseInt(all);
        bl = (bl / bl_all) * 360;
        var rotatenum = bl;
        if (bl > 180) {
            var blhtml = '';
            rotatenum = bl - 180;
            blhtml += '<div class="yuan_bl2">';
            blhtml += '<div class="yuan_bl4" style="-webkit-transform:rotate(' + rotatenum + 'deg);transform:rotate(' + rotatenum + 'deg);"></div>';
            blhtml += '</div>';
            //$('.yuan_bl1').remove($('.yuan_bl3'));
            $('.yuan_bl1').after(blhtml);
        } else {
            var blhtml = '';
            blhtml += '<div class="yuan_bl3" style="-webkit-transform:rotate(' + rotatenum + 'deg);transform:rotate(' + rotatenum + 'deg);"></div>';
            $('.yuan_bl1').append(blhtml);
        }
    })

    //select跳页
    function s_click(obj) {
        var num = 0;
        for (var i = 0; i < obj.options.length; i++) {
            if (obj.options[i].selected == true) {
                num++;
            }
        }

        if (num == 1) {
            var url = obj.options[obj.selectedIndex].value;
            var date = "<?=$status_date?>";
            var p = "<?=$nowPage?>";
            if (url == '') {

                location.href = '<?php echo base_url();?>member/bill_time?id=' + url + '&date=' + date;
            } else {
                location.href = '<?php echo base_url();?>member/bill_time?id=' + url + '&date=' + date;

            }

        }
    }

    //获取下个月时间
    $(".next").click(function () {
        var start = $('#date').val();
        $('#date').val(getNextMonth(start));
        var id = "<?=$status_id?>";
        //var p = "<?=$nowPage?>";
        location.href = '<?php echo base_url();?>member/bill_time?id=' + id + '&date=' + getNextMonth(start);
        // $('#end_time').datebox('setValue', getNextMonth(getNextMonth(start)));
    });

    function getNextMonth(date) {
        var arr = date.split('-');
        var year = arr[0]; //获取当前日期的年份
        var month = arr[1]; //获取当前日期的月份
        var day = arr[2]; //获取当前日期的日
        var days = new Date(year, month, 0);
        days = days.getDate(); //获取当前日期中的月的天数
        var year2 = year;
        var month2 = parseInt(month) + 1;
        if (month2 == 13) {
            year2 = parseInt(year2) + 1;
            month2 = 1;
        }
        var day2 = day;
        var days2 = new Date(year2, month2, 0);
        days2 = days2.getDate();
        if (day2 > days2) {
            day2 = days2;
        }
        if (month2 < 10) {
            month2 = '0' + month2;
        }
        var t2 = year2 + '-' + month2 + '-' + day2;
        return t2;
    }

    //获取上个月

    $(".pre").click(function () {
        var start = $('#date').val();
        $('#date').val(getPreMonth(start));
        var id = "<?=$status_id?>";
       // var p = "<?=$nowPage?>";
        location.href = '<?php echo base_url();?>member/bill_time?id=' + id + '&date=' + getPreMonth(start);
    });

    function getPreMonth(date) {
        var arr = date.split('-');
        var year = arr[0]; //获取当前日期的年份
        var month = arr[1]; //获取当前日期的月份
        var day = arr[2]; //获取当前日期的日
        var days = new Date(year, month, 0);
        days = days.getDate(); //获取当前日期中月的天数
        var year2 = year;
        var month2 = parseInt(month) - 1;
        if (month2 == 0) {
            year2 = parseInt(year2) - 1;
            month2 = 12;
        }
        var day2 = day;
        var days2 = new Date(year2, month2, 0);
        days2 = days2.getDate();
        if (day2 > days2) {
            day2 = days2;
        }
        if (month2 < 10) {
            month2 = '0' + month2;
        }
        var t2 = year2 + '-' + month2 + '-' + day2;
        return t2;
    }
</script>
<script>
    layui.use(['element', 'form', 'layedit', 'laydate', 'upload'], function () {
        var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
        var $ = layui.jquery
            , upload = layui.upload;

        //监听导航点击
        element.on('nav(demo)', function (elem) {
            //console.log(elem)
//      layer.msg(elem.text());
        });
        //日期
        laydate.render({
            elem: '#date-star'
        });
        laydate.render({
            elem: '#date-end'
        });
        laydate.render({
            elem: '#date'
        });
        //监听提交
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });
            return false;
        });


    });
</script>
<script type="text/javascript">
    $(function () {

        $(".deal-detail").click(function () {
            $(this).parent().find(".show-more").toggle();
        });
        $(".invoice-detail").click(function () {
            var url = $(this).attr('data-url');
            if (url) {
                $('.corporate-invoice-img').attr("src", url);
                $('.mask,.corporate-invoice-img-pop').show();
            } else {
                layer.msg('暂无发票详情')
            }
        });
//
//    $(".show-more").mouseleave(function(){
//      $(this).parent().find(".show-more").hide();
//    });
    });
</script>
</body>
</html>